home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group92c.txt / 000049_icon-group-sender _Wed Oct 28 16:17:55 1992.msg < prev    next >
Internet Message Format  |  1993-01-04  |  4KB

  1. Received: by cheltenham.cs.arizona.edu; Fri, 30 Oct 1992 20:58:57 MST
  2. Date: 28 Oct 92 16:17:55 GMT
  3. From: uchinews!ellis!goer@handies.ucar.edu  (Richard L. Goerwitz)
  4. Organization: University of Chicago Computing Organizations
  5. Subject: Re: confusing errors
  6. Message-Id: <1992Oct28.161755.26390@midway.uchicago.edu>
  7. References: <SPACKMAN.92Oct23174836@disco-sun6.dfki.uni-sb.de>, <1992Oct23.183537.6160@midway.uchicago.edu>, <SPACKMAN.92Oct28134152@disco-sol.dfki.uni-sb.de>
  8. Sender: icon-group-request@cs.arizona.edu
  9. To: icon-group@cs.arizona.edu
  10. Status: R
  11. Errors-To: icon-group-errors@cs.arizona.edu
  12.  
  13. stephen@acm.org writes:
  14. >
  15. >Now a language like Icon just doesn't commit to any easily explainable
  16. >syntax - perhaps avoiding criticisms about its design, but only by the
  17. >smokescreen method!
  18.  
  19. Actually, its syntax is very much like that of any Algol-like language.
  20. If you get a chance some time, just take a look in the latest grammar
  21. specs in _The Icon Programming Language_.  Some people (hackers mostly)
  22. are turned off by its Pascal-ish look (because of course anything Pas-
  23. calish looking must be evil :-)).
  24.  
  25. >|Maybe you are just baiting me, but the semicolon is not an operator with
  26. >|abstract semantics. It has semantics only in the sense that it directs the
  27. >|syntactic analyzer to map the concrete syntax to the abstract syntax in a
  28. >|certain way.
  29. >
  30. >???? It's probably hopeless to direct you to the revised report on algol
  31. >68 [this isn't a random insult, if you've seen the document you'll know
  32. >exactly what I mean - it isn't exactly very readable], but if it doesn't
  33. >have semantics somewthing is BADLY wrong with this language.
  34.  
  35. I'm making what I thought was a common distinction between concrete and
  36. abstract syntax (see, e.g., Aho-Sethi-Ullman, section 2.5).  Some operators
  37. only have relevance on the concrete level.  My point is that if such
  38. operators can easily be dispensed with, we should do so.
  39.  
  40. >Tell me, can you characterise for me the circumstances under which a
  41. >newline will NOT be interpreted as a go-on operator? When IS it safe to
  42. >break an expression?
  43.  
  44. This is the key question.  It's really quite simple, and requires the ad-
  45. dition of only about two hundred characters to the lexer.  Tokens can
  46. either begin or end an expression (or both or neither).  This is intuitive.
  47. For instance, if we get the operator := at the end of a line, then obviously
  48. the expression isn't complete.  If, however, we get := and then an identi-
  49. fier, then a newline, we have a complete expression and a SEMICOL (that's
  50. what the Icon tokenizer calls it, I think) token can be emitted.  It's all
  51. quite simple, and results in code that isn't cluttered with superfluous
  52. directives.  You might think that this arrangement results in strange er-
  53. rors, but in practice, one rarely makes an error that leads to unexpected
  54. groupings.  In lvalue := rvalue, one might spell rvalue wrong.  One almost
  55. never leaves rvalue out accidentally, though.  I can attest to this from
  56. much experience.
  57.  
  58. Try working with a language for a few weeks that has automatic semicolon
  59. insertion, and see whether you want to go back.  This argument can't be
  60. settled in the abstract.
  61.  
  62. Here's an example of where a newline should be ignored.  Any Icon programmer
  63. immediately recognizes the correct grouping, as I suspect even non Icon
  64. programmers would.  The semicolon after the string is wholly useless, though
  65. if you like it you can put it there:
  66.  
  67. procedure main()
  68.     ident :=
  69.     "this is an overlong line that just won't fit above, so I put it here"
  70.     write(ident)
  71. end
  72.  
  73. Here is an example of where semicolons are completely superfluous.  Can you
  74. imagine a language that was so poorly designed that you had to insert a
  75. useless operator all the time?
  76.  
  77. procedure main()
  78.     ident := "hello";
  79.     write(ident);
  80. end
  81.  
  82. procedure main()
  83.     ident := "hello"
  84.     write(ident)
  85. end
  86.  
  87. -- 
  88.  
  89.    -Richard L. Goerwitz              goer%midway@uchicago.bitnet
  90.    goer@midway.uchicago.edu          rutgers!oddjob!ellis!goer
  91.